<template>
  <div class="CinemasMap">
    <div class="CM-box">
      <div class="CM-box-wrap">
        <div class="CM-box-left">
          <img
            src="https://p1.meituan.net/deal/201208/22/1_0822151022.jpg@292w_292h_1e_1c"
            alt=""
          />
        </div>
        <div class="CM-box-right">
          <div class="CM-box-msg">
            <p class="name">万达影城</p>
            <p class="address ellipsis">
              硚口区解放大道十八号凯德广场05层。古田二路入口（古田二路生活一村公交站
            </p>
            <p class="phone ellipsis">联系电话：027-33333333</p>
            <div class="divider">
              <div class="divider-text">影院服务</div>
              <div class="divider-line"></div>
            </div>
            <div class="cinemas-server">
              <div>退</div>
              <div>未取票用户放映前60分钟可退票</div>
            </div>
            <div class="cinemas-server">
              <div>改签</div>
              <div>未取票用户放映前60分钟可改签</div>
            </div>
            <div class="cinemas-server">
              <div>3D眼镜</div>
              <div>免押金</div>
            </div>
          </div>
        </div>
        <div class="CM-map-wrap">
          <div id="CM-map"></div>
          <div class="showmap" @click="showBigMap"></div>
        </div>
      </div>
    </div>
    <el-dialog :show-close="false" :visible.sync="showmapflag">
      <div id="showmap-big"></div>
    </el-dialog>
  </div>
</template>
<style lang="scss" scoped>
.CinemasMap {
  .CM-box {
    height: 370px;
    background: url("https://s3plus.meituan.net/v1/mss_e2821d7f0cfe4ac1bf9202ecf9590e67/cdn-prod/file:5788b470/banner_bg.f7fd103e3b8c16b6f449cce43fc57f45.png")
      no-repeat;
    .CM-box-wrap {
      width: 1200px;
      height: 370px;
      position: relative;
      margin: 0 auto;
      .CM-box-left {
        width: 292px;
        height: 292px;
        border: 4px solid #fff;
        position: absolute;
        left: 0;
        bottom: -25px;
        background-color: #008cff;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .CM-box-right {
        position: absolute;
        left: 350px;
        top: 70px;
        color: #fff;
        .CM-box-msg {
          height: 300px;
          position: relative;
          .name {
            width: 340px;
            font-size: 26px;
            line-height: 32px;
            font-weight: 500;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            max-height: 64px;
            margin-bottom: 10px;
          }
          .address,
          .phone {
            width: 340px;
            font-size: 14px;
            line-height: 1.3;
            margin-bottom: 5px;
          }
          .divider {
            display: flex;
            align-items: center;
            .divider-text {
              color: #fff;
              padding: 10px 10px 10px 0;
              font-size: 14px;
            }
            .divider-line {
              flex: 1;
              height: 0.5px;
              background-color: #fff;
            }
          }
          .cinemas-server {
            font-size: 20px;
            height: 40px;
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            zoom: 0.5;
            div {
              &:first-child {
                width: 110px;
                height: 36px;
                line-height: 36px;
                text-align: center;
                border: 2px solid hsla(0, 0%, 100%, 0.6);
                border-radius: 4px;
                margin-right: 10px;
              }
            }
          }
          .ellipsis {
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
          }
        }
      }
      .CM-map-wrap {
        width: 200px;
        height: 200px;
        position: absolute;
        background-color: #fff;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        #CM-map {
          width: 200px;
          height: 200px;
        }
        .showmap {
          position: absolute;
          right: 0;
          bottom: 0;
          width: 36px;
          height: 29px;
          background: url("../../assets/images/showmap.png") no-repeat;
          background-size: 100% 100%;
        }
      }
    }
  }
  #showmap-big {
    width: 500px;
    height: 500px;
    margin: 0 auto;
  }
  /deep/ .el-dialog {
    width: 500px;
  }
  /deep/ .el-dialog__header {
    padding: 0;
  }
  /deep/ .el-dialog__body {
    padding: 0;
  }
}
</style>
<script>
import imginfo from "../../assets/js/getImg";
export default {
  data() {
    return {
      img: imginfo.data,
      showmapflag: false, // 地图控件
      lat: null,
      lng: null,
    };
  },
  methods: {
    initMapSmall() {
      var map = new qq.maps.Map(document.getElementById("CM-map"), {
        // 地图的中心地理坐标。30.458288,114.428304
        center: new qq.maps.LatLng(30.458288, 114.428304),
        zoom: 13,
      });

      var marker = new qq.maps.Marker({
        position: new qq.maps.LatLng(30.458288, 114.428304),
        map: map,
      });
    },
    initMapBig() {
      var map = new qq.maps.Map(document.getElementById("showmap-big"), {
        // 地图的中心地理坐标
        center: new qq.maps.LatLng(30.458288, 114.428304),
        zoom: 13,
      });
      var marker = new qq.maps.Marker({
        position: new qq.maps.LatLng(30.458288, 114.428304),
        map: map,
      });
      // var marker1 = new qq.maps.Marker({
      //   position: new qq.maps.LatLng(30.458100, 114.428304),
      //   map: map,
      // });
    },

    // 显示大地图
    showBigMap() {
      this.showmapflag = true;
      // 改为异步
      setTimeout(() => {
        this.initMapBig();
      }, 50);
    },

    showPosition(position) {
      // console.log(position);
      this.lat = position.lat; //
      this.lng = position.lng; //火星坐标 //TODO 实现业务代码逻辑
      console.log(this.lat, this.lng);
    },

    showErr() {
      //TODO 如果出错了调用此方法
      console.log("报错");
    },
  },

  created() {
    let geolocation = new qq.maps.Geolocation(
      "B6BBZ-CD7KU-YB3V5-23QYN-GLVSZ-73FNC",
      "mapqq"
    );
    geolocation.getLocation(this.showPosition, this.showErr);
  },

  mounted() {
    this.initMapSmall();
  },
};
</script>
